package com.qzsf.backend.mapper.sql;

import org.apache.ibatis.jdbc.SQL;

/*
 * @Author: Dennis Chen
 * @CreateTime: 2024/11/22 15:28 周五
 * @Email 1429278462@qq.com
 * @Remark 组织多条件筛选
 * @Version 1.0
 */
public class OrganizerSqlProvider {
    public String getOrganizerByCondition(String name) {
        return new SQL() {{
            SELECT("a.id,a.status,b.name,b.pic,b.contact_name,b.contact_email,b.contact_phone,b.description");
            FROM("userAuth a");
            LEFT_OUTER_JOIN("organizer_profile b on a.id = b.id");
            WHERE("a.role = 'organizer'");

            if(name != null && !name.trim().isEmpty()){
                WHERE("b.name like concat('%',#{name},'%')");
            }
        }}.toString();
    }
}
